import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// 导入侧边栏图片
// import dashboard from '@/assets/navIcons/clgl.png'

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '工作台', icon: 'eye-open' }
    }]
  },
  // 基础数据管理
  {
    path: '/basicData',
    component: Layout,
    meta: { title: '基础数据管理' },
    children: [
      {
        path: 'scope',
        name: 'scope',
        component: () => import('@/views/basicData/scope/index'),
        meta: { title: '机构管理' }
      },
      {
        path: 'organization',
        name: 'organization',
        component: () => import('@/views/basicData/organization/index'),
        meta: { title: '机构作业范围' }
      },
      {
        path: 'freight',
        name: 'freight',
        component: () => import('@/views/basicData/freight/index'),
        meta: { title: '运费管理' }
      }
    ]
  },
  // 车辆管理
  {
    path: '/carRegulate',
    component: Layout,
    meta: { title: '车辆管理' },
    children: [
      {
        path: 'VehicleManage',
        name: 'VehicleManage',
        component: () => import('@/views/carRegulate/VehicleManage/index'),
        meta: { title: '车型管理' }
      },
      {
        path: 'vehicleList',
        name: 'vehicleList',
        component: () => import('@/views/carRegulate/vehicleList/index'),
        meta: { title: '车辆列表' }
      },
      {
        path: 'vehicleRegister',
        name: 'vehicleRegister',
        component: () => import('@/views/carRegulate/vehicleRegister/index'),
        meta: { title: '回车登记' }
      }
    ]
  },
  // 员工管理
  {
    path: '/employee',
    component: Layout,
    meta: { title: '员工管理' },
    children: [
      {
        path: 'Courier',
        name: 'Courier',
        component: () => import('@/views/employee/Courier/index'),
        meta: { title: '快递员管理' }
      },
      {
        path: 'driver',
        name: 'driver',
        component: () => import('@/views/employee/driver/index'),
        meta: { title: '司机管理' }
      },
      {
        path: 'Scheduling',
        name: 'Scheduling',
        component: () => import('@/views/employee/Scheduling/index'),
        meta: { title: '排版管理' }
      },
      // 排版设置
      {
        path: 'Schedule-setting',
        name: 'setting',
        hidden: true,
        component: () => import('@/views/employee/Scheduling/Schedule-setting.vue'),
        meta: { title: '排版设置' }
      }
    ]
  },
  // 业务管理
  {
    path: '/Business',
    component: Layout,
    meta: { title: '业务管理' },
    children: [
      {
        path: 'Order',
        name: 'Order',
        component: () => import('@/views/Business/Order/index'),
        meta: { title: '订单管理' }
      },
      {
        // 派件
        path: 'waybill',
        name: 'waybill',
        component: () => import('@/views/Business/waybill/index'),
        meta: { title: '运单管理' }
      }
    ]
  },
  // 调度管理
  {
    path: '/scheduling',
    component: Layout,
    meta: { title: '调度管理' },
    children: [
      {
        path: 'transport',
        name: 'transport',
        component: () => import('@/views/scheduling/transport/index'),
        meta: { title: '运输任务管理' }
      },
      {
        path: 'course',
        name: 'course',
        component: () => import('@/views/scheduling/course/index'),
        meta: { title: '线路管理' }
      },
      {
        path: 'pickup',
        name: 'pickup',
        component: () => import('@/views/scheduling/pickup/index'),
        meta: { title: '取件管理' }
      },
      {
        path: 'delivery',
        name: 'delivery',
        component: () => import('@/views/scheduling/delivery/index'),
        meta: { title: '派件管理' }
      }
    ]

  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]
// 动态路由
const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
